package com.hn658.base.message.managermq.config;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

import com.hn658.framework.shared.utils.UUIDUtils;

@Component
public class MqClientIdConfig {
	
	private static String DEFAULT_CLIENT_ID = "DEFAULT_CLIENT_FACTORY";
	
	public String getCurrentClientId(){
		String clientIdTmp = System.getenv("clientId");
		
		if (StringUtils.isEmpty(clientIdTmp)) {
			clientIdTmp = System.getProperty("clientId");
		}
		
		if(StringUtils.isEmpty(clientIdTmp)){
			String env = System.getProperty("spring.profiles.active");
			if ("development".equalsIgnoreCase(env)) {
				clientIdTmp = UUIDUtils.getUUID();
			}
		}
		
		if(StringUtils.isEmpty(clientIdTmp)){
			clientIdTmp = DEFAULT_CLIENT_ID;
		}
		
		System.out.println("当前应用客户端ID:======="+clientIdTmp+"=====");
		return clientIdTmp;
	}
}
